import 'package:flutter/material.dart';  //dartUI包
import './first_pages.dart'; //引入首页
import './second_pages.dart';//引入第二页
import './third_pages.dart';//引入第三页

/*
底部导航栏
*/
class NavigatePages extends StatefulWidget{
  @override
  _NavigatePagesState createState() => _NavigatePagesState();
}

class _NavigatePagesState extends State<NavigatePages>{
  int _selectIndex = 0;

  //定义icon和文字
  final List<BottomNavigationBarItem> bottmTabs = [
    BottomNavigationBarItem(
      icon:Icon(Icons.home),
      title:Text("首页"),
    ),
    BottomNavigationBarItem(
      icon:Icon(Icons.all_inclusive),
      title:Text("自定义"),
    ),
    BottomNavigationBarItem(
      icon:Icon(Icons.person),
      title:Text("我的"),
    ),
  ];

  //定义要调用的类
  final List<Widget> tabBodies = [
    FirstPages(),
    SecondPages(),
    ThirdPages(),
  ];

  //事用const修饰一个在类内使用的变量
  static const TextStyle optionStyle = TextStyle(fontSize: 30,fontWeight: FontWeight.bold);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: tabBodies[_selectIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items:bottmTabs,
        currentIndex: _selectIndex,
        selectedItemColor: Colors.amber[800],
        unselectedItemColor: Colors.blue[800],
        onTap: (index){
          setState(() {
            _selectIndex = index;
          });
        },
      ),
    );
  }
}
